home *** CD-ROM | disk | FTP | other *** search
/ MacWorld Secrets (4th Edition) / Mac Secrets CD 4th Ed.toast / Apple Advanced Technologies / Apple Speech Technologies 1.5 / PlainTalk Developer Info / Speech Recognition Manager SDK / SR Sample Code / Speakable Items Example / Sources / Process & Finder Stuff / AppleEventUtils.c next >
Text File  |  1995-06-07  |  2KB  |  80 lines

  1.  #pragma segment AppleEventUtils
  2.  
  3. #include "Processes.h"
  4. #include "AppleEvents.h"
  5.  
  6. /*****************************************************************************************/
  7.  
  8. OSErr GetProcessLocation(StringPtr prompt, 
  9.                         LocationNameRec *theLocation, 
  10.                         PortInfoRec *thePortInfo);
  11.  
  12. OSErr SendAppleEvent1Param(LocationNameRec    *theLocation, 
  13.                             PortInfoRec        *thePortInfo, 
  14.                             AEEventClass    eventClass,
  15.                             AEEventID        eventID,
  16.                             DescType        dataType, 
  17.                             void            *dataPtr, 
  18.                             Size            dataSize);
  19.  
  20.  
  21. /*****************************************************************************************/
  22. /*****************************************************************************************/
  23.  
  24. OSErr GetProcessLocation(prompt, 
  25.                         theLocation, 
  26.                         thePortInfo)
  27.  
  28. StringPtr        prompt;
  29. LocationNameRec    *theLocation;
  30. PortInfoRec        *thePortInfo;
  31. {
  32.     OSErr err;
  33.         
  34.     err = PPCBrowser(prompt, prompt, false, theLocation, thePortInfo, (PPCFilterUPP) 0, (ConstStr32Param) 0);
  35.     return(err);
  36. }
  37.  
  38. /*****************************************************************************************/
  39.  
  40. OSErr SendAppleEvent1Param(theLocation, thePortInfo, 
  41.                             eventClass, eventID,
  42.                             dataType, dataPtr, dataSize)
  43. LocationNameRec    *theLocation;
  44. PortInfoRec        *thePortInfo;
  45. AEEventClass    eventClass;
  46. AEEventID        eventID;
  47. DescType        dataType;
  48. void            *dataPtr;
  49. Size            dataSize;
  50.             
  51. {
  52.     OSErr            err,err2;
  53.     TargetID        theTargetID;
  54.     AppleEvent        theAevt;
  55.     AEAddressDesc    theTarget;
  56.  
  57.     theTargetID.location = *theLocation;
  58.     theTargetID.name = thePortInfo->name;
  59.     err = AECreateDesc(typeTargetID, (Ptr)&theTargetID, (Size)sizeof(theTargetID), &theTarget);
  60.  
  61.     if (err == noErr) 
  62.         err = AECreateAppleEvent(eventClass, eventID, &theTarget, kAutoGenerateReturnID, kAnyTransactionID, &theAevt);
  63.  
  64.     if ((err == noErr) && (dataPtr != 0))
  65.         err = AEPutParamPtr(&theAevt, keyDirectObject, dataType, (Ptr) dataPtr, dataSize);
  66.  
  67.     if (err == noErr)
  68.         err = AESend(&theAevt, (AppleEvent *)0, kAEQueueReply+kAECanInteract + kAECanSwitchLayer, kAENormalPriority, 240, (AEIdleUPP) 0, (AEFilterUPP)0);
  69.  
  70.         /* Get rid of structures    */
  71.     err2 = AEDisposeDesc(&theAevt);
  72.     err2 = AEDisposeDesc(&theTarget);
  73.  
  74.     return(err);
  75. }
  76.  
  77.  
  78.  
  79. /*****************************************************************************************/
  80.